import BaseLabel_blxf from "../Base/BaseLabel";
import { EnumManager_blxf } from "../Manager/EnumManager";
import NodePool_blxf from "../Module/NodePool";
import { UtilsModule_blxf } from "../Module/UtilsModule";


const {ccclass, property} = cc._decorator;

/** 货币增加数 */

@ccclass
export default class IconNumItem_blxf extends cc.Component {

    @property({ type: cc.Node })
    numNode: cc.Node = null;

    @property({ type: cc.Node })
    numNode2: cc.Node = null;

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {

    }

    // update (dt) {}

    initData_blxf ( options: any ) {
        let { num, num2 } = options;

        this.numNode2.opacity = num2 !== undefined ? 255 : 0;

        UtilsModule_blxf.setText_blxf( this.numNode, `${num}` );
        UtilsModule_blxf.setText_blxf( this.numNode2, `${num2}` );

        this.node.opacity = 0;
        this.scheduleOnce(()=>{
            this.onAnimation_blxf();
        }, 0.8)
    }

    /** 上升动画 */
    onAnimation_blxf () {
        let { PREFAB_ICON_NUM_ITEM } = EnumManager_blxf.prefabNameType; 

        this.node.opacity = 255;
        let _delayTime: number = 0.8, _t: number = 1.5, _y: number = 100;
        cc.tween( this.node )
        // .delay( _delayTime )
        .by( _t, { y: _y, opacity: -100 }, cc.easeSineInOut())
        .call(()=>{
            // this.node.destroy();
            UtilsModule_blxf.setText_blxf( this.numNode2, `` );
            NodePool_blxf.put( PREFAB_ICON_NUM_ITEM, this.node );
        }).start();
    }

}
